﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Common;
using Common.Admin;
using Common.Controls;

namespace SLAdmin.UserControls
{
    public partial class EditCondition : UserControl
    {
        Condition _condition;
        int _conditionId;
        Study _study;
        Guid _studyId;
        App _myApp = App.GetApplication;
        StudyManager _studyManager = StudyManager.GetInstance();
        StudyDataClient _studyDataClient = new StudyDataClient();
        DialogHelper _dialogHelper = new DialogHelper();

        public delegate void ConditionUpdatedDelegate();
        public event ConditionUpdatedDelegate ConditionUpdated;
        public EditCondition()
        {
            InitializeComponent();
        }
        public EditCondition(Condition myCondition, Study Study)
        {
            InitializeComponent();
            _condition = myCondition;
            _conditionId = myCondition.ConditionId;
            _study = Study;
            _studyId = Study.StudyId;
            this.DataContext = myCondition;
            
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            _studyDataClient.UpdateCondition(_condition);
            ConditionUpdated();
        }

        private void UserControl_LayoutUpdated(object sender, EventArgs e)
        {
            StudyTabs.Width = this.ActualWidth;
        }

    }
}
